<?php $this->load->view('admin/Public/header'); ?>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
		  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
			  <legend>全部城市展示</legend>
		  </fieldset>
		  <div id="treeList" class="demo-tree demo-tree-box"></div>
      </div>
    </div>
  </div>
  <script>
  var data='<?php echo $list;?>';
  var list=JSON.parse(data);
  layui.config({
    base: '/public/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'contlist', 'table','tree', 'util'], function(){
  layer.msg('加载中，请耐心等待', {
	  icon: 16
	  ,shade: 0.01
  });
    var table = layui.table
    ,form = layui.form
  	,util = layui.util
  	,tree = layui.tree;
      //无连接线风格
      tree.render({
          elem: '#treeList'
          ,data: list
          ,showLine: false  //是否开启连接线
          // ,edit: ['add', 'update', 'del'] //操作节点的图标
          // ,click: function(obj){
          // layer.msg(JSON.stringify(obj.data));
      // }
      });
      layer.closeAll();
    //监听搜索
    form.on('submit(LAY-app-contlist-search)', function(data){
      var field = data.field;
      
      //执行重载
      table.reload('LAY-app-content-list', {
        where: field
      });
    });
    
    var $ = layui.$, active = {
      batchdel: function(){
        var checkStatus = table.checkStatus('LAY-app-content-list')
        ,checkData = checkStatus.data; //得到选中的数据

        if(checkData.length === 0){
          return layer.msg('请选择数据');
        }
      
        layer.confirm('确定删除吗？', function(index) {
          
          //执行 Ajax 后重载
          /*
          admin.req({
            url: 'xxx'
            //,……
          });
          */
          table.reload('LAY-app-content-list');
          layer.msg('已删除');
        });
      },
    }; 

    $('.layui-btn.layuiadmin-btn-list').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });

  });
  </script>
</body>
</html>
